package club.hicode.daydayup.redis.bf;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;
import org.junit.Test;

import java.nio.charset.Charset;

/**
 * Filter
 * @author Liu Chunfu
 * @date 2018-08-15 下午2:56
 **/
public class GuavaBloomFilter {

	/**
	 * 181
	 */
	@Test
	public void test2() {
		long start = System.currentTimeMillis();
		BloomFilter<String> bf = BloomFilter.create(Funnels.stringFunnel(Charset.forName("utf-8")), 100, 0.1);

		for (int i = 0; i < 100000; i++) {
			bf.put(i + "");
		}

		for (int i = 0; i < 100000; i++) {
			boolean b = bf.mightContain(i + "");
			if (b == false) {
				System.out.println(i + " check false");
			}
		}

		long end = System.currentTimeMillis();
		System.out.println(end - start);

	}

}
